package com.wanmait.movie.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wanmait.movie.entity.LobbyType;
import com.wanmait.movie.entity.VO.LobbyTypeVO;
import com.wanmait.movie.mapper.LobbyTypeMapper;
import com.wanmait.movie.service.ManageLobbyTypeService;
import org.springframework.beans.BeanUtils;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * ClassName: ManageLobbyTypeServiceImpl
 * Package: com.wanmait.movie.service.impl
 * Description:
 *
 * @Author Fengxd
 * @Create 2023/12/8 14:06
 * @Version 1.0
 */
@Service
public class ManageLobbyTypeServiceImpl extends ServiceImpl<LobbyTypeMapper, LobbyType> implements ManageLobbyTypeService {
    @Override
//    @Cacheable(value = "commonCache", unless = "#result == null")
    public List<LobbyTypeVO> getLobbyTypeInfo() {
        QueryWrapper<LobbyType> lobbyTypeQueryWrapper = new QueryWrapper<>();
        lobbyTypeQueryWrapper.select("id,lobby_type_name","insert_time","lobby_type_describe","sort");
        // 过滤不需要显示的属性
        return this.list(lobbyTypeQueryWrapper).stream().map(lobbyType -> {
            LobbyTypeVO lobbyTypeVO = new LobbyTypeVO();
            BeanUtils.copyProperties(lobbyType,lobbyTypeVO);
            return lobbyTypeVO;
        }).collect(Collectors.toList());
    }
}
